#ifndef _BACKDROP_SCROLL_H_
#define _BACKDROP_SCROLL_H_

#include "backdrop.h"

namespace backdrop
{
class BackdropLayer;

class BackdropScroll : public Backdrop
{
public:
	BackdropScroll(camera::FbCamera* pCam);
	virtual ~BackdropScroll();

	virtual Decal*					GetDecalSprite(const math::Vec2& Pos);
	virtual Decal*					GetDecalSprite(const math::Vec2& Pos, int Layer, bool Background = true);
	virtual bool					DeleteDecalSprite(Decal* pDecal);
	virtual void					ResetDecalPos();

	virtual void					PreRender();
	virtual void					PostRender();
	virtual void					Tick(float dt);
	virtual void					Clear();
	virtual void					ClearLevel();

	virtual void					SaveSpecial(script::WriteLua& Output);
	virtual void					LoadSpecial(LuaPlus::LuaState* pScript);

	virtual bool					ClampToTop() const { return true; }
	virtual bool					ClampToLeft() const { return true; }
	virtual bool					LockVerticalScroll() const { return false; }
	virtual bool					LockHorizontalScroll() const { return false; }
	virtual float					Left() const { return 0.0f; }
	virtual float					Right() const { return m_Size.x - 1.0f; }
	virtual float					Top() const { return 0.0f; }
	virtual float					Bottom() const { return m_Size.y - 1.0f; }
	virtual float					GetExtentW() const { return m_Size.x; }
	virtual float					GetExtentH() const { return m_Size.y; }

	const bool&						IsScrolling() { return m_IsScrolling; }
	const math::Vec2&				GetSize() { return m_Size; }

	BackdropLayer*					AddLayer(int LayerID = -1,
											 float Parallax = 1.0f,
											 bool Background = true,
											 const std::string& Name = "",
											 const math::Vec2& Pos = math::Vec2(0.0f, 0.0f),
											 const math::Vec2& Size = math::Vec2(1.0f, 1.0f),
											 bool UVScroll = false);

	unsigned int					GetLayerC(bool Background = true);
	BackdropLayer*					GetLayer(unsigned int idx, bool Background = true);
	void							InsertLayer(BackdropLayer* pLayer, int idx = -1, bool Background = true);
	void							DeleteLayer(BackdropLayer* pLayer, bool bDelete = true);
	void							SetLayerEnabled(unsigned int idx, bool bEnable = true, bool Background = true);

	virtual void					Scroll(const math::Vec2& pos, const bool bRelative = true, const bool bDelay = false);
	virtual void					SetSize(const math::Vec2& size);

protected:
	virtual BackdropLayer*			AddLayer(std::vector<BackdropLayer*>* pList,
											 const std::string& Image,
											 int LayerID,
											 float ParallaxSpeed,
											 const math::Vec2& Pos,
											 const math::Vec2& Size,
											 bool UVScroll);
	
protected:
	std::vector<BackdropLayer*>		m_Foreground;
	std::vector<BackdropLayer*>		m_Background;

	math::Vec2						m_Dest;
	math::Vec2						m_ScrollSpeed;
	math::Vec2						m_Size;

private:
	bool							m_IsScrolling;
};
} //namespace backdrop

#endif // _BACKDROP_SCROLL_H_
